import Compile from "./Compile.js";
import { observe } from "./observe.js";

class Vue{
    constructor(options){
        this.$options = options || {};
        this._data = options.data || undefined;
        observe(this._data);
        //将vue._data直接挂载到vue
        this._initData();
        new Compile(options.el,this)
    }
    _initData(){
        var self = this;
        Object.keys(this._data).forEach(key=>{
            Object.defineProperty(self,key,{
                get(){
                    return self._data[key];
                },
                set(newVal){
                    self._data[key] = newVal;
                }
            })
        })
    }
}
window.Vue=Vue